package com.LFL.ajyx;

public class Test {
    public static void main(String[] args) {
        System.out.println("Hello World!");
        //求平均分，总分和从大到小排序
        int[] scores = {89, -23, 64, 91, 119, 52, 73};
        int maxScore = 0;
        int minScore = 0;
        int sum = 0;
        for (int i = 0; i < scores.length; i++) {
            if (scores[i] < 0 || scores[i] > 100) {
                System.out.println("输入的成绩有误！");
                break;
            }
            if (scores[i] > maxScore) {
                maxScore = scores[i];
            }
            if (scores[i] < minScore) {
                minScore = scores[i];
            }
            sum += scores[i];
        }
        System.out.println("最高分：" + maxScore);
        System.out.println("最低分：" + minScore);
        System.out.println("平均分：" + sum / scores.length);
        //冒泡排序
        for (int i = 0; i < scores.length - 1; i++) {
            for (int j = 0; j < scores.length - 1 - i; j++) {
                if (scores[j] < scores[j + 1]) {
                    int temp = scores[j];
                    scores[j] = scores[j + 1];
                    scores[j + 1] = temp;
                }
            }
        }
        System.out.println("从大到小排序：");
        for (int i = 0; i < scores.length; i++) {
            System.out.print(scores[i] + "\t");
        }
    }

}
